package com.wanxi.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * @Author:Doteon
 * @createDate:2023/3/16
 * @version: 1.0
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 解决静态资源无法访问
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
        // 解决swagger无法访问
        registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        // 解决swagger的js文件无法访问
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");



        // 文件上传
        registry.addResourceHandler("/img/**").addResourceLocations("file:G:\\fuzhuang-06-1017\\target\\classes\\static\\img\\");
        registry.addResourceHandler("/upload/**").addResourceLocations("file:G:\\fuzhuang-06-1017\\target\\classes\\static\\upload\\");
        super.addResourceHandlers(registry);

    }

}
